<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.baoku.wap.dao.*"  %>
<%@ page import="com.baoku.wap.entity.*" %>
<%@ page import="com.baoku.wap.util.*" %>
<%@ include file="session.jsp" %>
<%
	int knowledgeid = 0;
	
	try{
	    knowledgeid = Integer.parseInt(request.getParameter("knowledgeid"));
	}catch(Exception e){
		String ref = request.getHeader("REFERER");
		response.sendRedirect(ref);
		return;
	}
		
	if (login){	
		String userid = (String)session.getAttribute("id");
		
		if (new UserFactory().saveFavorite(userid,knowledgeid)){
			String ref = request.getHeader("REFERER");
			response.sendRedirect(ref);
		}else {
			//out.println("存在");
			response.sendRedirect("had.jsp?id="+knowledgeid);
			
		}
	}else{
		response.sendRedirect("favorite_err.jsp?id="+knowledgeid);
	}
	
%>
